<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<script src="../js/jquery-3.4.1.min.js"></script>
		<script>
			$(function() {
				alert("页面加载完成，执行js函数！")
				// $.get("ajaxUser","id=1000&name=tomcat",function(result){
				// 	// console.log(result)
				// 	for(let user of result){
				// 		console.log(user)
				// 		let id = user.id
				// 		let name=user.name
				// 		let age = user.age
				// 		let sex = user.sex
				// 		let tr ="<tr><td>"+id+"</td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td></tr>"
				// 		$("#tab1").append(tr)
				// 	}
				// })
				$.ajax({
					type: "get",
					url: "ajaxUser",
					data: "id=1000&name=tomcat猫",
					success: function(result) {
						for (let user of result) {
							console.log(user)
							let id = user.id
							let name = user.name
							let age = user.age
							let sex = user.sex
							let tr = "<tr><td>" + id + "</td><td>" + name + "</td><td>" + age + "</td><td>" + sex + "</td></tr>"
							$("#tab1").append(tr)

						}
					},
					error: function(result) {
						alert("系统错误，请稍等")
					},
					async: true,



				})
			})
		</script>
		<title>您好Springboot</title>
	</head>
	<body>
		<table id="tab1" border="1px" width="65%" align="center">
			<tr>
				<td colspan="6" align="center">
					<h3>学生信息</h3>
				</td>
			</tr>
			<tr>
				<th>编号</th>
				<th>姓名</th>
				<th>年龄</th>
				<th>性别</th>
				<th></th>
			</tr>

		</table>
	</body>
</html>
